using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Home_ContactAttributes : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnAddNewAttribute_Click(object sender, EventArgs e)
    {
        PlacementManager.ContactAttributeComponent oContactAttributeC = new PlacementManager.ContactAttributeComponent();
        PlacementManager.ContactAttribute oContactAttribute = new PlacementManager.ContactAttribute();

        oContactAttribute.AttributeName = this.txtNewAttributeName.Text;
        oContactAttribute.CreatedBy = User.Identity.Name;
        oContactAttribute.DateCreated = DateTime.Now;
        oContactAttribute.DateUpdated = DateTime.Now;
        oContactAttribute.DivisionId = Int32.Parse(Session["DivisionId"].ToString());
        oContactAttribute.IsActive = true;
        oContactAttribute.UpdatedBy = User.Identity.Name;

        oContactAttributeC.Insert(oContactAttribute);

        this.gvContactAttributes.DataBind();
        this.txtNewAttributeName.Text = string.Empty;
    }
    protected void gvContactAttributes_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        PlacementManager.ContactAttributeComponent oContactAttribC = new PlacementManager.ContactAttributeComponent();
        PlacementManager.ContactAttribute oAttrib = oContactAttribC.SelectOne(Int32.Parse(this.gvContactAttributes.DataKeys[e.RowIndex].Value.ToString()));

        e.NewValues.Add("ContactAttributeId", oAttrib.ContactAttributeId);
        e.NewValues.Add("CreatedBy", oAttrib.CreatedBy);
        e.NewValues.Add("DateCreated", oAttrib.DateCreated);
        e.NewValues.Add("DivisionId", oAttrib.DivisionId);
        e.NewValues.Add("DateUpdated", DateTime.Now);
        e.NewValues.Add("UpdatedBy", User.Identity.Name);
    }
}
